package org.common.controller.base;

import com.google.common.collect.Lists;
import org.springframework.http.HttpStatus;

import java.util.List;

/**
 * @Description
 * @Date 2022/12/22 11:04
 * @Author pq
 */
public class OperationResult<T> {
    private Boolean result = false;
    private int httpStatus;
    private String code;
    private String msg;
    private T data;
    private List<String> errorMsg;

    public OperationResult() {
        this.httpStatus = HttpStatus.OK.value();
        this.code = "";
        this.errorMsg = Lists.newArrayList();
    }

    public Boolean isResult() {
        return this.result;
    }

    public OperationResult<T> setData(T data) {
        this.data = data;
        return this;
    }

    public OperationResult<T> setCode(String code) {
        this.code = code;
        return this;
    }

    public OperationResult<T> setHttpStatus(int httpStatus) {
        this.httpStatus = httpStatus;
        return this;
    }

    public OperationResult<T> setResult(boolean result) {
        this.result = result;
        return this;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public void setResult(Boolean result) {
        this.result = result;
    }

    public void setErrorMsg(List<String> errorMsg) {
        this.errorMsg = errorMsg;
    }

    public Boolean getResult() {
        return result;
    }

    public int getHttpStatus() {
        return httpStatus;
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public T getData() {
        return data;
    }

    public List<String> getErrorMsg() {
        return errorMsg;
    }
}
